#include<stdio.h>
int main()
{
    int year=0,month=0;
    while(scanf("%d %d",&year,&month)!=EOF)
    {
        if((year%4==0&&year%400!=0)||year%400==0)
    {
        switch(month)
    {
        case 1:printf("31");break;
        case 2:printf("29");break;
        case 3:printf("31");break;
        case 4:printf("30");break;
        case 5:printf("31");break;
        case 6:printf("30");break;
        case 7:printf("31");break;
        case 8:printf("31");break;
        case 9:printf("30");break;
        case 10:printf("31");break;
        case 11:printf("30");break;
        case 12:printf("31");break;
        default:printf("error");
    }
    }
    else
    {
         switch(month)
    {
        case 1:printf("31");break;
        case 2:printf("28");break;
        case 3:printf("31");break;
        case 4:printf("30");break;
        case 5:printf("31");break;
        case 6:printf("30");break;
        case 7:printf("31");break;
        case 8:printf("31");break;
        case 9:printf("30");break;
        case 10:printf("31");break;
        case 11:printf("30");break;
        case 12:printf("31");break;
        default:printf("error");
    }
    }
        printf("\n");
    }
    return 0;
}
